package com.zkk.web;

import com.zkk.pojo.Manager;
import com.zkk.service.ManagerService;
import com.zkk.service.impl.ManagerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/login")
public class Login extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        Manager manager=new Manager();
        ManagerService managerService=new ManagerServiceImpl();
        manager.setUsername(username);
        manager.setPassword(password);
        Manager login = managerService.login(manager);
        req.setAttribute("admin",login);
        req.getRequestDispatcher("/judgeLogin.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
